/*
 * WarehouseApp.java
 */
package warehouse;

import java.text.DecimalFormat;
import java.util.TreeMap;
import org.jdesktop.application.Application;
import org.jdesktop.application.SingleFrameApplication;

/**
 * The main class of the application.
 */
public class WarehouseApp extends SingleFrameApplication {

    /**
     * At startup create and show the main frame of the application.
     */
    @Override
    protected void startup() {
        show(new WarehouseView(this));
    }

    /**
     * This method is to initialize the specified window by injecting resources.
     * Windows shown in our application come fully initialized from the GUI
     * builder, so this additional configuration is not needed.
     */
    @Override
    protected void configureWindow(java.awt.Window root) {
    }

    /**
     * A convenient static getter for the application instance.
     *
     * @return the instance of WarehouseApp
     */
    public static WarehouseApp getApplication() {
        return Application.getInstance(WarehouseApp.class);
    }

    /**
     * Main method launching the application.
     */
    public static void main(String[] args) {
        launch(WarehouseApp.class, args);
        Database db = new Database();
        DecimalFormat twoDForm = new DecimalFormat("##0.00");
        
        //System.out.println("Najlepsza hala: " + db.getTheBestHallSpectatorsRate());
        //System.out.println(db.getPlayersAttacksRate(1));
        /*
        System.out.println("\nNajlepsza skuteczność ataku.");
        int i = 1;
        String name = "";
        String firstName = "";
        String teamName = "";
        TreeMap<Integer, Double> sorted_map = db.getBestPlayersAttackRate();
        for (int key : sorted_map.keySet()) {
            name = db.getPlayersNameById(key);
            firstName = db.getPlayersFirstNameById(key);
            teamName = db.getPlayersTeamNameById(key);
            System.out.println(i + ") " + firstName + " " + name + " " + teamName  + " / rate: " + twoDForm.format(sorted_map.get(key)));
            i++;
            if (i > 10) {
                break;
            }
        }

        System.out.println("\nNajlepsza skuteczność bloku:");
        i = 1;
        name = "";
        firstName = "";
        teamName = "";
        sorted_map = db.getBestPlayersBlocksRate();
        for (int key : sorted_map.keySet()) {
            name = db.getPlayersNameById(key);
            firstName = db.getPlayersFirstNameById(key);
            teamName = db.getPlayersTeamNameById(key);
            System.out.println(i + ") " + firstName + " " + name + " " + teamName  + " / rate: " + twoDForm.format(sorted_map.get(key)));
            i++;
            if (i > 10) {
                break;
            }
        }

        System.out.println("\nNajlepsza skuteczność przyjecia:");
        i = 1;
        name = "";
        firstName = "";
        teamName = "";
        sorted_map = db.getBestPlayersGambitsRate();
        for (int key : sorted_map.keySet()) {
            name = db.getPlayersNameById(key);
            firstName = db.getPlayersFirstNameById(key);
            teamName = db.getPlayersTeamNameById(key);
            System.out.println(i + ") " + firstName + " " + name + " " + teamName  + " / rate: " + twoDForm.format(sorted_map.get(key)));
            i++;
            if (i > 10) {
                break;
            }
        }

        System.out.println("\nNajlepsi sędziowie:");
        i = 1;
        name = "";
        sorted_map = db.getBestArbitersRate();
        for (int key : sorted_map.keySet()) {
            name = db.getArbitersNameById(key);
            System.out.println(i + ") " + firstName + " " + name + " " + teamName  + " / rate: " + twoDForm.format(sorted_map.get(key)));            i++;
            if (i > 10) {
                break;
            }
        }
         * */

    }

}
